package com.deyun.charpt02

import kotlin.coroutines.experimental.buildSequence

fun main(args: Array<String>) {

    for (i in fabonacci)
    {
        println(i)
        if(i>100)break
    }
}

val fabonacci= buildSequence {
    yield(1)

    var cur=1
    var next=1

    while (true)
    {
        yield(next)
        val temp=cur+next
        cur=next
        next=temp
    }
}